<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<script src="./index.js"></script>

<body>
  <div class="wrapper">
    <!-- <img class="img" src="https://w.wallhaven.cc/full/rd/wallhaven-rdwjj7.jpg" > -->
  </div>
</body>
<style>
  * {
    margin: 0;
    padding: 0;
  }

  html,
  body {
    min-height: 100vh;
    width: 100%;
    background-color: #333;
    overflow: hidden;
  }

  .wrapper {
    margin: auto;
    margin-top: 200px;
    width: 1200px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background-size: cover;
  }
</style>
<script>

  window.onload = () => {

    const wrapper = document.querySelector('.wrapper')
    
    const img = new Image()
    img.classList.add('img')
    img.src = 'https://w.wallhaven.cc/full/rd/wallhaven-rdwjj7.jpg'
    
    img.onload = () => {
      console.log('加载完毕')
      wrapper.appendChild(img)
    }

  }

</script>

</html>